Load Module and Object based on their id

I have module id and object id,
I want to load module and then load object based on id which i have, so that i can easily edit that object.

basically my requirement is to change object's attribute value based on id which i have.

Please suggest me proper solution.

Thanks & Regards,
Hardik Shah
SystemAdmin - Tue Sep 07 07:33:04 EDT 2010

Re: Load Module and Object based on their id
Peter_Albert - Tue Sep 07 07:57:42 EDT 2010

You need

Module edit(string name [,bool disp[, bool silent[, bool loadStandardView]]])

to open the module in exclusive edit mode, and

Object object(int absno[,Module m])

to get a handle to the object. Note that the latter does not find filtered objects, hence if you load anything than the standard view then you should turn filtering off after loading the module. A code fragment you could start with could look like this

string yourModuleName = ...
int yourObjectID = ...
string yourAttName = ...
string yourAttValue = ...
 
Module mod = edit(yourModuleName, true, false, true)
Object obj = object(yourObjectID, mod)
if (!null obj)
{
  if (canModify(obj.yourAttName)){obj.yourAttName = yourAttValue}
}

 


Regards,

Peter

 

Re: Load Module and Object based on their id
SystemAdmin - Tue Sep 07 08:02:44 EDT 2010

Peter_Albert - Tue Sep 07 07:57:42 EDT 2010

You need

Module edit(string name [,bool disp[, bool silent[, bool loadStandardView]]])

to open the module in exclusive edit mode, and

Object object(int absno[,Module m])

to get a handle to the object. Note that the latter does not find filtered objects, hence if you load anything than the standard view then you should turn filtering off after loading the module. A code fragment you could start with could look like this

string yourModuleName = ...
int yourObjectID = ...
string yourAttName = ...
string yourAttValue = ...
 
Module mod = edit(yourModuleName, true, false, true)
Object obj = object(yourObjectID, mod)
if (!null obj)
{
  if (canModify(obj.yourAttName)){obj.yourAttName = yourAttValue}
}

 


Regards,

Peter

 

Thanks it works partially,
With this I can load object dynamically but if I want to load module also based on it then can you suggest solution.

Thanks & Regards,
Hardik Shah

Re: Load Module and Object based on their id
SystemAdmin - Tue Sep 07 08:08:15 EDT 2010

SystemAdmin - Tue Sep 07 08:02:44 EDT 2010
Thanks it works partially,
With this I can load object dynamically but if I want to load module also based on it then can you suggest solution.

Thanks & Regards,
Hardik Shah

I come up with initial solution like iterate all modules of the project and check with its unique id with passed id
and if it is matched then load that module.

but in this solution i have to iterate all module, so is there a better solution.

Thanks & Regards,
Hardik Shah

Re: Load Module and Object based on their id
Peter_Albert - Tue Sep 07 08:11:10 EDT 2010

SystemAdmin - Tue Sep 07 08:08:15 EDT 2010
I come up with initial solution like iterate all modules of the project and check with its unique id with passed id
and if it is matched then load that module.

but in this solution i have to iterate all module, so is there a better solution.

Thanks & Regards,
Hardik Shah

Ah o.k., I sort of overlooked that you wrote that you only have the unique ID of the module, not its name. In that case you can edit the module with

Module mod = edit(fullname itemFromID(moduleID))

given that the ID is stored in the string variable moduleID.
Regards

Peter

Re: Load Module and Object based on their id
SystemAdmin - Tue Sep 07 08:32:11 EDT 2010

Peter_Albert - Tue Sep 07 08:11:10 EDT 2010

Ah o.k., I sort of overlooked that you wrote that you only have the unique ID of the module, not its name. In that case you can edit the module with

Module mod = edit(fullname itemFromID(moduleID))

given that the ID is stored in the string variable moduleID.
Regards

Peter

Thanks a lot...
It works exactly what i wanted...

Thanks & Regards,
Hardik Shah